package com.note.simpleadmin.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Objects;

/***
 *@ClaseName:TbOrderItem
 *
 *@Decription:
 *
 *@Author: xubingbing
 *
 *@Date:2019/2/22 0022 23:02
 */
@Entity
@Table(name = "tb_order_item", schema = "simpleshop", catalog = "")
public class TbOrderItem {
    private String id;
    private Integer num;
    private String detail;
    private Double discount;
    private String goodsName;
    private String orderId;
    private BigDecimal marketPrice;
    private String remark;
    private String goodsSpecId;
    private String goodsId;
    private String thumbnail;
    private BigDecimal salePrice;
    private TbOrder order;

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "num")
    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    @Basic
    @Column(name = "detail")
    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @Basic
    @Column(name = "discount")
    public Double getDiscount() {
        return discount;
    }

    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    @Basic
    @Column(name = "goods_name")
    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }


    @Basic
    @Column(name = "market_price")
    public BigDecimal getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(BigDecimal marketPrice) {
        this.marketPrice = marketPrice;
    }

    @Basic
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Basic
    @Column(name = "goods_spec_id")
    public String getGoodsSpecId() {
        return goodsSpecId;
    }

    public void setGoodsSpecId(String goodsSpecId) {
        this.goodsSpecId = goodsSpecId;
    }

    @Basic
    @Column(name = "goods_id")
    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    @Basic
    @Column(name = "thumbnail")
    public String getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(String thumbnail) {
        this.thumbnail = thumbnail;
    }

    @Basic
    @Column(name = "sale_price")
    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbOrderItem that = (TbOrderItem) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(num, that.num) &&
                Objects.equals(detail, that.detail) &&
                Objects.equals(discount, that.discount) &&
                Objects.equals(goodsName, that.goodsName) &&
                Objects.equals(orderId, that.orderId) &&
                Objects.equals(marketPrice, that.marketPrice) &&
                Objects.equals(remark, that.remark) &&
                Objects.equals(goodsSpecId, that.goodsSpecId) &&
                Objects.equals(goodsId, that.goodsId) &&
                Objects.equals(thumbnail, that.thumbnail) &&
                Objects.equals(salePrice, that.salePrice);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, num, detail, discount, goodsName, orderId, marketPrice, remark, goodsSpecId, goodsId, thumbnail, salePrice);
    }
    @JsonIgnore
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)
    @JoinColumn(name="order_id")
    public TbOrder getOrder() {
        return order;
    }

    public void setOrder(TbOrder order) {
        this.order = order;
    }
}
